package com.li.day.day17;

public class TestSiSuo {
    public static void main(String[] args) {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                synchronized (xiaoming.yashua){
                    System.out.println("有牙刷了");
                    synchronized (xiaoming.yagao){
                        System.out.println("有牙膏了可以刷牙了");
                    }
                }
            }
        };
        Runnable runnable1 = new Runnable() {
            @Override
            public void run() {
                synchronized (xiaoming.yagao){
                    System.out.println("有牙膏了");
                    synchronized (xiaoming.yashua){
                        System.out.println("有牙刷了可以刷牙了");
                    }
                }
            }
        };
        Thread thread = new Thread(runnable,"小明");
        Thread thread1 = new Thread(runnable1, "小明");
        thread.start();
        thread1.start();
    }
}
 class xiaoming{
    public static String yashua="我要牙膏";
    public static String yagao="我要牙刷";
 }
